package com.coderdream.chapter19.state.sample;

public class NightState implements State {

	private static NightState singleton = new NightState();

	/**
	 * 构造函数为private
	 */
	private NightState() {
	}

	/**
	 * 取得唯一的对象实例
	 * 
	 * @return
	 */
	public static State getInstance() {
		return singleton;
	}

	/**
	 * 设定时间 (non-Javadoc)
	 * 
	 * @see com.coderdream.chapter19.state.sample.State#doClock(com.coderdream.chapter19.state.sample.Context,
	 *      int)
	 */
	public void doClock(Context context, int hour) {
		if (9 <= hour && hour < 17) {
			context.changeState(DayState.getInstance());
		}
	}

	/**
	 * 使用金库
	 */
	public void doUse(Context context) {
		context.recordLog("异常：晚间使用金库！");
	}

	/**
	 * 警铃
	 */
	public void doAlarm(Context context) {
		context.callSecurityCenter("警铃（晚间）");
	}

	/**
	 * 一般通话
	 */
	public void doPhone(Context context) {
		context.callSecurityCenter("晚间的通话录音");
	}

	/**
	 * 输出字符串
	 * 
	 * @see java.lang.Object#toString()
	 */
	public String toString() {
		return "[晚间]";
	}
}
